package com.event.binlog.properties;

import lombok.Data;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.Serializable;

/**
 * @Description 数据库binlog配置
 * @Author Bing
 * @Date 2025/1/17 17:29
 */
@Data
@Component
@ConditionalOnProperty(name = "db.binlog.enable", havingValue = "true")
@ConfigurationProperties(prefix = "db.binlog")
public class DbBinlogProperties implements Serializable {
    // binlog监听配置路径
    private String binlogListenConfigPath;
    // 监听锁超时时间
    private Integer lockTime;
    // 续期时间
    private Integer renewalTime;
    // 是否持久化(续读)
    private Boolean persistence;
    // 监听地址
    private String host;
    // 监听端口
    private Integer port;
    // 监听用户名
    private String username;
    // 监听密码
    private String password;
    // 监听库名
    private String database;

    public boolean hasDbConfig(){
        return host != null && port != null && username != null && password != null && database != null;
    }
}